import Dep from './dep';

export default class Watcher {
  constructor(vm, key, cb) {
    this.vm = vm;
    this.key = key;
    this.cb = cb;

    Dep.target = this;
    this.oldValue = this.vm[key];
    Dep.target = null;
  }
  update(newValue) {
    if (newValue === this.oldValue) {
      return;
    }
    this.cb(newValue);
  }
}
